//
//  LHTopAndButtomLable.m
//  Loohoo
//
//  Created by 陈镇 on 2025/4/7.
//

#import "LHTopAndButtomLable.h"

@interface LHTopAndButtomLable ()

@property(nonatomic,strong) QMUILabel *topLable;
@property(nonatomic,strong) QMUILabel *bottomLable;


@end
@implementation LHTopAndButtomLable





-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self addSubview:self.topLable];
        [self addSubview:self.bottomLable];
        self.topAndBottomSp = 5;
    }
    return self;
}

-(QMUILabel *)topLable{
    if (!_topLable) {
        _topLable = [[QMUILabel alloc] init];
        _topLable.textAlignment = NSTextAlignmentCenter;
    }
    return _topLable;
}
-(QMUILabel *)bottomLable{
    if (!_bottomLable) {
        _bottomLable = [[QMUILabel alloc] init];
        _bottomLable.textAlignment = NSTextAlignmentCenter;
    }
    return _bottomLable;
}
-(void)layoutSubviews{
    [self createFrame];
}

-(void)createFrame{
    [_topLable sizeToFit];
    _topLable.frame = CGRectMake(0, 0, self.width, _topLable.height);
    
    
    _topLable.top = self.height / 2  - _topLable.height  - self.topAndBottomSp/2;
    
    [_bottomLable sizeToFit];
    _bottomLable.frame = CGRectMake(0, _topLable.bottom + self.topAndBottomSp, self.width, _topLable.height);

}
-(void)setTopText:(NSString *)topText topColor:(UIColor *)topColor topFont:(UIFont *)topFont bottomText:(NSString *)bottomText bottomColor:(UIColor *)bottomColor bottomFont:(UIFont *)bottomFont{
    
    self.topLable.text = topText;
    self.topLable.textColor = topColor;
    self.topLable.font = topFont;
    self.bottomLable.text = bottomText;
    self.bottomLable.textColor = bottomColor;
    self.bottomLable.font = bottomFont;
    [self createFrame];
}
@end
